home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 8
/
Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso
/
Aminet
/
comm
/
tcp
/
Netdial4_0.lha
/
AmiTCP_Netdial4.0
/
netdial.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1980-05-28
|
11KB
|
328 lines
/* dialnet.rexx */
/* */
/* Version 1.0, 11 December 1993, by P.J. Rovero */
/* 1.2, 19 December 1993 */
/* 1.3, 30 December 1993, by K. Raquel Sanborn (raquels@uhunix) */
/* 1.4, 3 January 1994, Fix reboot Amiga without lose of CSLIP */
/* 1.5, 5 January 1994, Fix mounting of APIPE: */
/* 1.6, 6 January 1994, Add BREAK C support and "PROTECT +S" */
/* 1.7, 6 January 1994, Add FAILTAT 21 for mount >NIL: APIPE: */
/* 2.0, 20 December 1994, Redesign by Wes Tatters */
/* for AmiTCP 4.0 */
/* Now uses parameter passing instead of */
/* script building. */
/* Calls dialnet.connect to launch AmiTCP */
/* 2.1, 1 March 1995, Configured for AUSNET @ world.net */
/* This service needs Login: before Slip: */
/* */
/* An ARexx script that will dial a terminal server, connect, determine */
/* the dynamically assigned IP address, and start the proper components */
/* of AmiTCP 4.x. The script uses rexxserdev.library v5.x by Joseph M. */
/* Stivaletta. */
/* */
/* Inspired by Dave Bolen's REXX/2 SLIPUP.CMD for IBM OS/2 TCPIP 1.2.1 */
/* */
/* and AmiTCP_dialup10 by K. Raquel Sanborn */
/* */
/* ---------------------------------------------------------------------- */
/* Define general strings and other initialization stuff */
say 'Setting Control Variables...'
cr = '0d'x
crlf = '0d0a'x
lf = '0a'x
say 'Setting User Variables...'
dtimeout = 30 /* Dial time out in Seconds */
ctimeout = 15 /* Connect time out in Secs */
/************************ SITE INFORMATION ****************************/
/* These variables should be altered to reflect your local connection */
slip_ip = '0.0.0.0' /* Assigned at Login */
host_name = 'World.net' /* Ausnet Domain Name */
host_ip = '192.190.215.5' /* Ausnet - World.net */
dialstr = 'ATDT 131494'||cr /* Put your Telephone Number */
logprompt = 'sername:' /* Put your Login Prompt here */
passprompt = 'assword:' /* Put your Password Prompt here */
slipprompt = '>' /* Put your Server Prompt here */
slip_cmd = 'slip /compressed default'||cr /* Slip start command goes here */
iptype = 'cslip0' /* slip0 for SLIP sites */
/* cslip0 for CSLIP sites */
/************************ USER INFORMATION *****************************/
/* */
/* AUSNET USERS ONLY NEED TO SET THESE LINES */
amiganame = 'wtatters' /* put your Amiga user name here */
username = 'wtatters'||cr /* Ausnet user name here - same as amigname*/
passwd = 'passwordamiga'||cr /* Put Ausnet passwd here */
/* */
/**************************************************************************/
say 'Setting Modem Variables...'
at_cmd = 'AT'||cr
response = 'OK'
modeminit = 'ATZ'||cr
modemescape = '+++'
connectstr = 'CONNECT'
busystr = 'BUSY'
nocarrierstr = 'NO CARRIER'
nodialtonestr = 'NO DIALTONE'
/**************************************************************************/
/* Start the required libraries */
say 'Opening libraries...'
check = addlib('rexxsupport.library', 0, -30, 0)
if (check == 0) then say 'rexxsupport library did not open...'
check = addlib('rexxserdev.library', 0, -30, 0)
if (check == 0) then say 'rexxserdev did not open...'
/* Open the serial device and talk to the modem */
say 'Setting up serial device...'
serhandle = SerOpen('serial.device', 0)
check = SerClear(serhandle)
check = SerSetParms( serhandle, 19200, 8, N, 1, 0 )
/* Clean up on "BREAK C" */
buffer = allocmem( 4096 )
junk = c2d( buffer )
signal on break_c
/* Initialize Modem */
say 'Initializing Modem'
result = SerWrite( serhandle, '+++', length( '+++' ) )
check = delay(200)
result = SerWrite( serhandle, modeminit, length( modeminit ) )
say 'Waiting for '||response
call wait_str( response )
/* Dial & wait for a connection and the modem status string */
dtime = 0
say 'Dialing the terminal server... '
check = 0
do forever
if (check == 0) then
do
result = SerWrite( serhandle, dialstr, length( dialstr))
check = 1
totalstr = ''
end
status = SerQuery( serhandle )
parse upper var status valid bytes_read status_bits .
rcvdstr = SerRead( serhandle, junk, bytes_read )
totalstr = totalstr||rcvdstr
dtime = dtime + 1
if ( dtime >= dtimeout ) then
do
say Dialer timed out !!!
result = break_c()
end
say "Dialing: "||totalstr
test = pos(connectstr, totalstr)
if (test ~= 0) then leave
test = pos(busystr, totalstr)
if (test ~= 0) then
do
result = delay( 500 )
check = 0
end
test = pos(nocarrierstr, totalstr)
if (test ~= 0) then exit 20
test = pos(nodialtonestr, totalstr)
if (test ~= 0) then exit 20
result = delay(100)
end
totalstr = ''
say 'Modem has connected to the terminal server...'
check = delay(50)
check = SerFlush( serhandle, 'R')
check = delay(50)
/* send CR to wake up terminal server */
say 'Sent CR to server...'
check = SerWrite( serhandle, cr, length( cr ))
say 'Waiting for CSLIP Server... '
check = 0
online = 0
totalstr = ''
ctime = 0
do forever
status = SerQuery( serhandle )
parse upper var status valid bytes_read status_bits .
rcvdstr = SerRead( serhandle, junk, bytes_read )
totalstr = totalstr||rcvdstr
say totalstr
ctime = ctime + 1
if ( ctime >= ctimeout ) then
do
say Dialer could not negotiate connection !!!
result = break_c()
end
test = pos( 'No response', totalstr )
if ( test ~= 0 ) then
do
say 'Connection failed ...'
result = break_c()
end
test = pos( logprompt, totalstr )
if ( test ~= 0 ) then
do
ctime = 0
totalstr = ''
online = online + 1
say 'Received user prompt...'
check = SerWrite( serhandle, username, length( username ))
check = SerRead( serhandle, junk, length(username))
say 'Sent Username, now waiting for password prompt...'
end
test = pos( passprompt, totalstr )
if ( test ~= 0 ) then
do
ctime = 0
totalstr = ''
online = online + 2
say 'Received password prompt...'
check = SerWrite( serhandle, passwd, length( passwd ))
say 'Sent password, now waiting for Terminal...'
end
test = pos( slipprompt, totalstr )
if ( test ~= 0 ) then
do
ctime = 0
totalstr = ''
online = online + 3
say 'Received Connection prompt sending CSlip Command ...'
check = SerWrite( serhandle, slip_cmd, length( slip_cmd ) )
check = SerRead( serhandle, junk, length( slip_cmd ) )
end
if (online == 6) then leave
result = delay(100)
end
totalstr = ''
say 'Connection completed, now wait for IP addresses...'
address command
'wait 2 secs'
call wait_str('address')
say 'CSLIP address received from Host system...'
/* Ok, now we have all the data we need to start Cslip */
/* Close down the serial port but leave the line up (ignore DTR) */
check = SerClose( serhandle )
result = startslip()
check = freemem(buffer,4096)
exit result
/* ------------------------------------------------------------- */
/* Exit point for "Break C" or ^C */
/* ------------------------------------------------------------- */
break_c:
say 'Cleaning up before exit...'
say 'Initializing Modem'
result = SerWrite( serhandle, '+++', length( '+++' ) )
check = delay(200)
result = SerWrite( serhandle, modeminit, length( modeminit ) )
check = SerClose( serhandle )
say 'Serial Port closed'
check = freemem(buffer,4096)
exit
/* ------------------------------------------------------------- */
/* procedure startslip */
/* */
/* Start and configure AmiTCP for SLIP */
/* ------------------------------------------------------------- */
startslip:
parse var rcvdstr . 'IP address is ' a '.' b '.' c '.' d '.'.
slip_ip = a||'.'||b||'.'||c||'.'||d
say 'AmiTCP:bin/netdial.connect starting'
'AmiTCP:bin/netdial.connect '||host_name||' '||host_ip||' '||slip_ip||' '||amiganame||' '||iptype
return 0
/* ------------------------------------------------------------- */
/* Subroutine wait_str returns when argument string is received */
/* ------------------------------------------------------------- */
wait_str:
teststr = arg(1)
check = 0
do until (check ~= 0)
status = SerQuery( serhandle )
parse upper var status valid bytes_read status_bits .
rcvdstr = SerRead( serhandle, junk, bytes_read )
check = pos(teststr,rcvdstr)
test = delay(50)
end
return